package metu.tespit.entity.course;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.jboss.seam.annotations.Transactional;

/**
 
 * @created 13 Nis 2012
 */
@Entity
@Table(name="schedule")
public class Schedule implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 6173682531231156506L;

	@Id @GeneratedValue
	private Long id;
	
	@OneToMany(mappedBy="schedule", cascade=CascadeType.ALL)
	private List<Activity> activities=new ArrayList<Activity>();
	
	@OneToOne
	private Course course;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setCourse(Course course) {
		this.course = course;
	}

	public Course getCourse() {
		return course;
	}

	public void setActivities(List<Activity> activities) {
		this.activities = activities;
	}

	public List<Activity> getActivities() {
		return activities;
	}
	
	public List<Activity> getCurrentActivities(){
		List<Activity> retlist= new ArrayList<Activity>();
		for (Activity ac : activities){
			if(ac.getDueDate().after(new Date())){
				retlist.add(ac);
			}
		}
		return retlist;
	}
	
}
